package cn.cy.behavior.observer.inter.pattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yangxq
 * @desc
 * @date 2025-05-11
 */
public abstract class investment {

    protected String name;
    protected double price;

    private List<Observer> observers = new ArrayList<>();

    public void attach(Observer observer) {
        observers.add(observer);
    }

    public void detach(Observer observer) {
        observers.remove(observer);
    }

    protected void notifyObservers() {
        for (Observer observer : observers) {
            observer.update(price);
        }
    }

}
